package com.zjs.server.mongodb.contorller;

import com.zjs.server.mongodb.pojo.Person;
import com.zjs.server.mongodb.service.ServicePerson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PersonContorller {

    @Autowired
    private ServicePerson servicePerson;

    @RequestMapping(value = "/addPerson",method = RequestMethod.GET)
    public String addPerson(){
        Person p = new Person("tff","123",19);
        return  servicePerson.addPerson(p);
    }
    @RequestMapping(value = "/updatePerson",method = RequestMethod.GET)
    public String updatePerson(){
        Person p = new Person("tff","123",22);
        return servicePerson.updatePerson(p);
    }

    @RequestMapping(value = "/deletePerson/{name}",method = RequestMethod.GET)
    public String deletePerson(@PathVariable(value = "name") String name){
        return servicePerson.deletePerson(name);
    }
    @RequestMapping(value = "/findPerson/{name}",method = RequestMethod.GET)
    public Person findPerson(@PathVariable(value = "name") String name){
       return servicePerson.findPerson(name);
    }
}
